#pragma once


#include "Message.h"

#include "PhysicsModuleMessages.h"


namespace _MMESSAGE_
{
	namespace _PHYSICS_
	{
		class PMM_SetCollisionCheck: 
			public _FOGGE_::_MSG_::Message
		{
			FoDeclareRegisterFuntion(PMM_SetCollisionCheck);
		public:
			/*virtual*/
			void ClearData()
			{
				m_ptrDataObject1=NULL;
				m_ptrDataObject2=NULL;
				m_wGroupID1=32;
				m_wGroupID2=32;

			}

			_FOGGE_::_GDB_::foDataObject* m_ptrDataObject1;
			_FOGGE_::_GDB_::foDataObject* m_ptrDataObject2;

			WORD m_wGroupID1;//!<an integer between 0 and 31
			WORD m_wGroupID2;//!<an integer between 0 and 31


			bool m_bCollision;


			
		};

		class PMM_SetActorCollisionGroup: 
			public _FOGGE_::_MSG_::Message
		{
			FoDeclareRegisterFuntion(PMM_SetActorCollisionGroup);
		public:
			/*virtual*/
			void ClearData()
			{
				m_ActorInfoVector.clear();
			}

			struct ActorInfo
			{
				_FOGGE_::_GDB_::foDataObject* ptrDataObject;
			
				WORD wGroupID;//!<an integer between 0 and 31
			};

			std::vector<ActorInfo> m_ActorInfoVector;


			
		};

		class PMM_SubscribeForCollisionReport: 
			public _FOGGE_::_MSG_::Message
		{
			FoDeclareRegisterFuntion(PMM_SubscribeForCollisionReport);
		public:
			/*virtual*/
			void ClearData()
			{
				m_ptrDataObject1=NULL;
				m_ptrDataObject2=NULL;
				m_wGroupID1=32;
				m_wGroupID2=32;

				m_bWhenOnTouch=false;
				m_bWhenStartTouch=false;
				m_bWhenEndTouch=false;

			}

			_FOGGE_::_GDB_::foDataObject* m_ptrDataObject1;
			_FOGGE_::_GDB_::foDataObject* m_ptrDataObject2;

			WORD m_wGroupID1;//!<an integer between 0 and 31
			WORD m_wGroupID2;//!<an integer between 0 and 31



			bool m_bWhenOnTouch;
			bool m_bWhenStartTouch;
			bool m_bWhenEndTouch;
		};

		class PMM_PointCollisionCheck: 
			public _FOGGE_::_MSG_::Message
		{
			FoDeclareRegisterFuntion(PMM_PointCollisionCheck);
		public:
			/*virtual*/
			void ClearData()
			{
				m_PointVector.clear();
			}

			std::vector<_FOMATH::Vector> m_PointVector;
		};

		class PMM_LineCollisionCheck: 
			public _FOGGE_::_MSG_::Message
		{
			FoDeclareRegisterFuntion(PMM_LineCollisionCheck);
		public:
			/*virtual*/
			void ClearData()
			{
				m_LineVector.clear();
			}

			struct Line
			{
				_FOMATH::Vector start;
				_FOMATH::Vector end;
			};

			std::vector<Line> m_LineVector;
		};

		class PMM_ActorCollisionCheck: 
			public _FOGGE_::_MSG_::Message
		{
			FoDeclareRegisterFuntion(PMM_ActorCollisionCheck);
		public:
			/*virtual*/
			void ClearData()
			{
				m_ActorVector.clear();
			}

			
			std::vector<_FOGGE_::_GDB_::foDataObject* > m_ActorVector;
		};

		class PMM_CollisionCheckResult: 
			public _FOGGE_::_MSG_::Message
		{
			FoDeclareRegisterFuntion(PMM_CollisionCheckResult);
		public:
			/*virtual*/
			void ClearData()
			{
				m_CollisionInfoVector.clear();
			}

			struct CollisionInfo
			{
				_FOGGE_::_GDB_::foDataObject* collideActor;//!<valid only line,and point
				_FOGGE_::_GDB_::foDataObject* collideActor2;//!<valid only when contect
				_FOMATH::Vector collideLocation;//!<valid ony line ,and point
				_FOMATH::Vector collideNormal;//!<valid ony line ,and point
				float collideDist;//!<valid ony line

				int index;//!< result index;

			};

			
			std::vector<CollisionInfo> m_CollisionInfoVector;
		};

		void RegisterCollisionMessages(::_FOGGE_::_MSG_::MessageManager* ptrMessagaManager);
	}
}

#define SendSetCollisionCheckMessage(collisionFlag,dataObject1,dataObject2)\
{\
	_PMMSG::PMM_SetCollisionCheck *ptrTCC=FoDynamicCast(_PMMSG::PMM_SetCollisionCheck,GetNewMassage(_PMMSG::ePMM_SetCollisionCheck ));\
	ptrTCC->m_ptrDataObject1=dataObject1;\
	ptrTCC->m_ptrDataObject2=dataObject2;\
	ptrTCC->m_bCollision=collisionFlag;\
	ptrTCC->PushReceiver(_FOGGE_::eEMID_Physics);\
	SendMessage(ptrTCC);\
}

#define SendSetCollisionCheckMessageByGroup(collisionFlag,groupID1,groupID2) \
{\
	_PMMSG::PMM_SetCollisionCheck *ptrTCC=FoDynamicCast(_PMMSG::PMM_SetCollisionCheck,GetNewMassage(_PMMSG::ePMM_SetCollisionCheck ));\
	ptrTCC->m_wGroupID1=groupID1;\
	ptrTCC->m_wGroupID2=groupID2;\
	ptrTCC->m_bCollision=collisionFlag;\
	ptrTCC->PushReceiver(_FOGGE_::eEMID_Physics);\
	SendMessage(ptrTCC);\
}